﻿namespace Radar.Test
{
    using System;
    using NUnit.Framework;

    [TestFixture]
    public class ResolveContextTest
    {
        private ResolveContext context;

        [SetUp]
        public void SetUp()
        {
            context = new ResolveContext();
        }

        [Test, ExpectedException(typeof(ArgumentNullException))]
        public void ShouldThrowOnPushNull()
        {
            context.Push(null);
        }

        [Test, ExpectedException(typeof(ArgumentNullException))]
        public void ShouldThrowOnPopNull()
        {
            context.Pop(null);
        }

        [Test, ExpectedException(typeof(ArgumentNullException))]
        public void ShouldThrowOnContainsNull()
        {
            context.Contains(null);
        }

        [Test]
        public void ShouldPush()
        {
            context.Push("some key");
            Assert.That(context.Contains("some key"));
        }

        [Test]
        public void ShouldPop()
        {
            context.Push("some key");
            context.Pop("some key");
            Assert.That(!context.Contains("some key"));
        }

        [Test, ExpectedException(typeof(CircularReferenceException))]
        public void ShouldThrowOnPushSameKeyTwice()
        {
            context.Push("some key");
            context.Push("some key");
        }
    }
}